<template>
	<view class="container" v-if="show">
		<scroll-view :scroll-y="true" :style="{height:height}" class="content scroll-box" >
			<!-- @touchend.prevent 滑动的时候也会触发触摸事件 -->
			<text class="item" v-for="item in list" :key="item.unicode"@touchstart="touchstart" @touchmove="touchmove" @touchend.prevent="select(item)">
				{{ item.emoji }}
			</text>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: () => false
			},
			height: {
				type: String,
				default: '388rpx',
				isMoving: false
			}
		},
		data() {
			return {
				list: [],
			}
		},
		created() {
			this.init()
		},
		methods: {
			init() {
				this.list = this.$RongIMEmoji.list
			},
			select(item) {
				if (this.isMoving) {
					return;
				}
				this.$emit('select', item)
				// this.$emit('update:show', false)
			},
			touchmove() {
				this.isMoving = true;
			},
			touchstart() {

				this.isMoving = false;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		z-index: 99;
		width: 100%;
		background: #ffffff;
		// border-radius: 20px;
		// box-shadow: 0px 0px 4px #b3abab;
		padding: 20rpx;
		box-sizing: border-box;

		.content {
			// overflow: auto;
			width: 100%;
			height: 388rpx;
		}

		.item {
			cursor: pointer;
			display: inline-block;
			width: 12.5%;
			height: 78rpx;
			line-height: 78rpx;
			text-align: center;
			font-size: 52rpx;
			// 禁用默认的浏览器行为，从而减少延迟
			touch-action: manipulation;
		}
	}
</style>